package com.xrkj.miniprogram.server.controller;


import com.xrkj.miniprogram.server.entity.DigitalDevice;
import com.xrkj.miniprogram.server.service.LongitudeAndLatitudeService;
import com.xrkj.miniprogram.server.service.QueryInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController("")
public class DeviceInformationController {
    @Autowired
    QueryInformationService queryInformationService;
    @Autowired
    LongitudeAndLatitudeService longitudeAndLatitudeService;

    @RequestMapping("getAllDeviceInformation")
    public List<DigitalDevice> getAllDeviceInformation(){
        return queryInformationService.getAllDevice(1);
    }

    @RequestMapping("submitLongitudeAndLatitude")
    public Map<String,String> submitLongitudeAndLatitude(int id,double longitude,double latitude){
        Map<String,String> resultMap=new HashMap<>();
        try{
            longitudeAndLatitudeService.updateLongitudeAndLatitude(id,longitude,latitude);
            resultMap.put("msg","success");
        }catch (Exception e){
            resultMap.put("msg","failed");
        }
        return resultMap;
    }

}
